package com.eight.VoteController;

import com.eight.entity.Picture;
import com.eight.pageInfo.PageableTools;
import com.eight.voteServer.PictureServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class PictureController {

    @Autowired
    private PictureServer pictureServer;

    @Autowired
    private PageableTools pageableTools;

    @ResponseBody
    @RequestMapping("pictureCount")
    public Long pictureCount() {

        Long count = pictureServer.pictureCount();

        return count;
    }

    @ResponseBody
    @RequestMapping("pictureInformation{page}")
    public List<Picture> pictureInformation(@PathVariable("page") Integer page) {

        Page<Picture> pictures = pictureServer.findAll(pageableTools.basicPage(page));

        return pictures.getContent();
    }

    /**
     * 描述：最热排行
     * @return
     */
    @ResponseBody
    @RequestMapping("findAllByList")
    public List<Picture> findAllByList() {

        List<Picture> picture=pictureServer.findAllByList();

        return picture;
    }


}
